figure.Reloj = new Class({
    Extends: figure.Dial,

    initialize: function(id, css, value, unit, min, capacity, step) {
        this.parent(id, css, value, unit, min, capacity, step);
    },

    updateDial: function(event) {
        var dial = $('#' + event.data.id);
        dial.text(event.data.me.value + (event.data.unit ? event.data.unit: ''));
        dial.css('width', DIAL_WIDTH + event.data.me.value.toString().length + event.data.unit.length);
    },

    addEvents: function() {
        var controlElement = this.controlElement;
        controlElement.on('overtime', function overtime(event, basculaFermentacion) {
            if (figure.stopAnimation) {
                window.setTimeout(function() { overtime(event, basculaFermentacion) }, figure.speed);
                return;
            }
            var valueAsInt = parseInt(basculaFermentacion.controlElement[0].value);
            var maxValueAsInt = parseInt(basculaFermentacion.controlElement[0].max);
            var value = parseInt(controlElement[0].value);
            if (valueAsInt == maxValueAsInt || value > 0) {
                value += 2;
                controlElement[0].value = value;
                controlElement.trigger('change');
            }
            window.setTimeout(function() { overtime(event, basculaFermentacion)}, figure.speed);
        });
    }
});

